Skip to content

Conversation

Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Oct 12, 2025

The sonic-simd crate detects SIMD features at compile time, which is inconvenient for binary distribution.

This PR copies the source code from sonic-rs and refactors it to include runtime SIMD feature detection. The implementation is not elegant but functions effectively.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Brooooooklyn Brooooooklyn force-pushed the 10-12-refactor_runtime_detect_simd_features branch from 47b30b9 to 1abe914 Compare October 12, 2025 16:01
Copy link

codspeed-hq bot commented Oct 12, 2025

CodSpeed Performance Report

Merging #29 will degrade performances by 7.11%

Comparing 10-12-refactor_runtime_detect_simd_features (6a3bf55) with main (4a7dad2)

Summary

❌ 1 regression
✅ 2 untouched
⏩ 9 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
Instrumentation short string escape simd 2.2 µs 2.4 µs -7.11%

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Brooooooklyn Brooooooklyn force-pushed the main branch 2 times, most recently from d525b70 to fff65a9 Compare October 13, 2025 04:15
@Brooooooklyn Brooooooklyn force-pushed the 10-12-refactor_runtime_detect_simd_features branch from 55b4022 to 5329627 Compare October 13, 2025 04:21
@Brooooooklyn Brooooooklyn force-pushed the 10-12-refactor_runtime_detect_simd_features branch from d4b63fc to 70b51da Compare October 13, 2025 04:52
@Brooooooklyn Brooooooklyn requested a review from Copilot October 13, 2025 04:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactors the codebase to implement runtime SIMD feature detection by copying and adapting source code from sonic-rs, replacing the compile-time detection provided by the sonic-simd crate. This enables better binary distribution compatibility across different hardware platforms.

  • Adds local SIMD abstraction modules for different architectures (SSE2, AVX2, AVX512, NEON, and generic fallback)
  • Implements runtime feature detection using is_x86_feature_detected! and is_aarch64_feature_detected!
  • Refactors the main escape function to dynamically select SIMD implementations based on available CPU features

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/simd/traits.rs Defines portable SIMD traits and interfaces
src/simd/v128.rs Generic 128-bit SIMD implementation as fallback
src/simd/sse2.rs SSE2-specific SIMD implementation for x86/x86_64
src/simd/neon.rs NEON-specific SIMD implementation for AArch64
src/simd/mod.rs Module organization for SIMD implementations
src/simd/bits.rs Bitmask utilities and implementations
src/simd/avx512.rs AVX512-specific SIMD implementation
src/simd/avx2.rs AVX2-specific SIMD implementation
src/simd/README.md Documentation for the SIMD module
src/lib.rs Main library refactored for runtime SIMD detection
benches/escape.rs Added correctness assertions in benchmarks
Cargo.toml Removed sonic-simd dependency and added debug symbols

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Brooooooklyn Brooooooklyn merged commit 1339b96 into main Oct 13, 2025
13 checks passed
@Brooooooklyn Brooooooklyn deleted the 10-12-refactor_runtime_detect_simd_features branch October 13, 2025 05:12
@github-actions github-actions bot mentioned this pull request Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant